global root_path "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"

clear all
set maxvar 32767

cd "$root_path/02_ready_for_PSIDclean"

use individ_family_2005.dta, clear

cd "$root_path/03_ready_for_TAXSIM"

rename ER25002 family_id

gen unique_id_crossys=(ER30001*1000) + ER30002

gen sequence_num=ER33802

rename ER30000 release_number
rename ER30001 interview_number_1986
rename ER30002 person_number


** Race

* wife
gen white_w=0
replace white_w=1 if ER27297==1 & ER27298==0 & ER27299==0 & ER27300==0

gen black_w=0
replace black_w=1 if ER27297==2 & ER27298==0 & ER27299==0 & ER27300==0

gen native_amer_w=0
replace native_amer_w=1 if ER27297==3 & ER27298==0 & ER27299==0 & ER27300==0

gen asian_w=0
replace asian_w=1 if ER27297==4 & ER27298==0 & ER27299==0 & ER27300==0

*gen latino_w=0
*replace latino_w=1 if ER27297==5 & ER27298==0 & ER27299==0 & ER27300==0

gen other_w=0
replace other_w=1 if ER27297>=5 
replace other_w=1 if ER27298!=0 | ER27299!=0 | ER27300!=0

gen any_race_w=white_w+black_w+native_amer_w+asian_w+other_w

*  3,721 have no recorded race in OUR data
*  3,524: no wife present
*  3,721-3,524 are mixed race so we did not code them yet

* husband
gen white_h=0
replace white_h=1 if ER27393==1 & ER27394==0 & ER27395==0 & ER27396==0

gen black_h=0
replace black_h=1 if ER27393==2 & ER27394==0 & ER27395==0 & ER27396==0

gen native_amer_h=0
replace native_amer_h=1 if ER27393==3 & ER27394==0 & ER27395==0 & ER27396==0

gen asian_h=0
replace asian_h=1 if ER27393==4 & ER27394==0 & ER27395==0 & ER27396==0

*gen native_h=0
*replace native_h=1 if ER27393==5 & ER27394==0 & ER27395==0 & ER27396==0

gen other_h=0
replace other_h=1 if (ER27393>=5) | ER27393==0
replace other_h=1 if ER27394!=0 | ER27395!=0 | ER27396!=0

gen any_race_h=white_h+black_h+native_amer_h+asian_h+other_h
sum any_race_h

** State of residence.
rename ER25003 state_residence

** RAW FIELDS.
** Marriage stuff.
rename ER25023 marital_status_head
rename ER25018 sex_head

gen married=0
replace married=1 if marital_status_head==1

keep if (sequence_num==1 & married==0) | (sequence_num==1 & married==1) | (sequence_num==2 & married==1)


** Children.
rename ER25020 children
** Ages.
rename ER25017 age_head
rename ER25019 age_wife

** GENERATED FIELDS.
rename ER27908 farm_inc_head_gen
rename ER27932 rent_inc_head_gen
rename ER27911 unincorp_assetpt_inc_head_gen
rename ER27925 gardening_inc_head_gen
rename ER27974 alimony_inc_head_gen
rename ER27945 rent_inc_wife_gen
rename ER27941 unincorp_assetpt_inc_wife_gen
rename ER27936 interest_inc_head_gen
rename ER27949 interest_inc_wife_gen

rename ER27953 taxable_inc_hh_gen
rename ER27943 labor_inc_wife_gen
rename ER27934 dividend_inc_head_gen
rename ER27947 dividend_inc_wife_gen
rename ER27931 labor_inc_head_gen

rename ER26529 alimony_given

rename ER27962 nonva_retire_inc_head_gen
rename ER27988 retire_annuities_inc_wife_gen

rename ER28031 socsec_inc_head_gen
rename ER28033 socsec_inc_wife_gen

rename ER27956 ssi_inc_head_gen
rename ER27984 ssi_inc_wife_gen
rename ER27960 vapension_inc_head_gen
rename ER27970 workerscomp_inc_head_gen
rename ER27992 workerscomp_inc_wife_gen
rename ER27954 tanf_inc_head_gen
rename ER27982 tanf_inc_wife_gen
rename ER27958 otherwelfare_inc_head_gen
rename ER27986 otherwelfare_inc_wife_gen
rename ER27972 childsupport_inc_head_gen
rename ER27994 childsupport_inc_wife_gen

** Rent.
rename ER25063 rent_amount
rename ER25064 rent_amount_unit

** Taxes.
rename ER25036 property_tax_annual

** Deductions.
rename ER26515 whether_itemized
rename ER26516 itemized_charitable
rename ER26517 itemized_medical

** Child care.
rename ER25628 childcare_expense

** Unemployment.
rename ER27968 unemployment_inc_head_gen
rename ER27990 unemployment_inc_wife_gen

** Mortgage payments.
rename ER25042 mortgage1_principle_remaining
rename ER25046 mortgage1_interest_rate_wholenum
rename ER25047 mortgage1_interest_rate_fraction

** Food consumption.
rename ER25684 food_stamps
rename ER25685 food_stamps_unit
rename ER25688 food_homestamps
rename ER25689 food_homestamps_unit
rename ER25692 food_deliveredstamps
rename ER25693 food_deliveredstamps_unit
rename ER25695 food_awaystamps
rename ER25696 food_awaystamps_unit
rename ER25698 food_home
rename ER25699 food_home_unit
rename ER25702 food_delivered
rename ER25703 food_delivered_unit
rename ER25705 food_away
rename ER25706 food_away_unit


*donations

rename ER27449 whether_donation25_religious
rename ER27450 whether_donation_religious
rename ER27451 amount_donation_religious
rename ER27456 whether_donation_combo
rename ER27457 amount_donation_combo
rename ER27462 whether_donation_needy
rename ER27463 amount_donation_needy
rename ER27468 whether_donation_health
rename ER27469 amount_donation_health
rename ER27474 whether_donation_education
rename ER27475 amount_donation_education
rename ER27480 whether_donation_youth
rename ER27481 amount_donation_youth
rename ER27486 whether_donation_culture
rename ER27487 amount_donation_culture
rename ER27492 whether_donation_community
rename ER27493 amount_donation_community
rename ER27498 whether_donation_environment
rename ER27499 amount_donation_environment
rename ER27504 whether_donation_peace
rename ER27505 amount_donation_peace
rename ER27510 whether_donation_other
rename ER27511 amount_donation_other
rename ER27510A donation_type_other_org	

*volunteering

// Religious
rename ER27529 calcul_yr_hs_reli_hd
rename ER27539 calcul_yr_hs_reli_wf

rename ER27530 calcul_yr_hs_reli_right_hd
rename ER27540 calcul_yr_hs_reli_right_wf

rename ER27531 your_estim_yr_hs_reli_hd
rename ER27541 your_estim_yr_hs_reli_wf

rename ER27533 estim_yr_hs_reli_extra_hd
rename ER27543 estim_yr_hs_reli_extra_wf

// Youth
rename ER27548 calcul_yr_hs_youth_hd
rename ER27557 calcul_yr_hs_youth_wf

rename ER27549 calcul_yr_hs_youth_right_hd
rename ER27558 calcul_yr_hs_youth_right_wf

rename ER27550 your_estim_yr_hs_youth_hd
rename ER27559 your_estim_yr_hs_youth_wf

rename ER27552 estim_yr_hs_youth_extra_hd
rename ER27561 estim_yr_hs_youth_extra_wf

// Senior
rename ER27566 calcul_yr_hs_senior_hd
rename ER27575 calcul_yr_hs_senior_wf

rename ER27567 calcul_yr_hs_senior_right_hd
rename ER27576 calcul_yr_hs_senior_right_wf

rename ER27568 your_estim_yr_hs_senior_hd
rename ER27577 your_estim_yr_hs_senior_wf

rename ER27570 estim_yr_hs_senior_extra_hd
rename ER27579 estim_yr_hs_senior_extra_wf

//Health
rename ER27584 calcul_yr_hs_health_hd
rename ER27593 calcul_yr_hs_health_wf

rename ER27585 calcul_yr_hs_health_right_hd
rename ER27594 calcul_yr_hs_health_right_wf

rename ER27586 your_estim_yr_hs_health_hd
rename ER27595 your_estim_yr_hs_health_wf

rename ER27588 estim_yr_hs_health_extra_hd
rename ER27597 estim_yr_hs_health_extra_wf

//Needy
rename ER27602 calcul_yr_hs_needy_hd
rename ER27611 calcul_yr_hs_needy_wf

rename ER27603 calcul_yr_hs_needy_right_hd
rename ER27612 calcul_yr_hs_needy_right_wf

rename ER27604 your_estim_yr_hs_needy_hd
rename ER27613 your_estim_yr_hs_needy_wf

rename ER27606 estim_yr_hs_needy_extra_hd
rename ER27615 estim_yr_hs_needy_extra_wf

//Social Change
rename ER27620 calcul_yr_hs_change_hd
rename ER27629 calcul_yr_hs_change_wf

rename ER27621 calcul_yr_hs_change_right_hd
rename ER27630 calcul_yr_hs_change_right_wf

rename ER27622 your_estim_yr_hs_change_hd
rename ER27631 your_estim_yr_hs_change_wf

rename ER27624 estim_yr_hs_change_extra_hd
rename ER27633 estim_yr_hs_change_extra_wf

//Other

rename ER27639 calcul_yr_hs_other_hd
rename ER27649 calcul_yr_hs_other_wf

rename ER27640 calcul_yr_hs_other_right_hd
rename ER27650 calcul_yr_hs_other_right_wf

rename ER27641 your_estim_yr_hs_other_hd
rename ER27651 your_estim_yr_hs_other_wf

rename ER27643 estim_yr_hs_other_extra_hd
rename ER27653 estim_yr_hs_other_extra_wf

rename ER27656 hs_other_religious
rename ER27658 hs_other_youth
rename ER27660 hs_other_senior
rename ER27662 hs_other_health
rename ER27664 hs_other_needy
rename ER27666 hs_other_socialchange
rename ER27667A volunteer_type_other_oth
rename ER27668 hs_type_other

rename ER25406 hr_wage_spouse
rename ER25148 hr_wage_hd
rename ER25910 tot_wage_hd
rename ER26281 tot_wage_spouse
rename ER27886 tot_hs_worked_head
rename ER27897 tot_hs_worked_spouse

rename ER27442 religion_hd
rename ER27346 religion_spouse
rename ER28043A rural

rename ER26165 whether_unemployed_head
rename ER26284 whether_unemployed_spouse

drop ER*

save fam2005er-small.dta, replace 
